package activity.study.initmysql;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @RequestMapping("/res")
    public String res() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "{\"code\":200,\"msg\":\"短信申请发送成功！\",\"smsContent\":\"一口吃的监考老师，发现一个学生在作弊，便气急败坏地指着那学生吼道：“你…你…你…你…你竟敢作弊，站起来！ 话刚说完，有5名学生站了起来。！\",\"reqSerialNo\":\"192929229\",\"smsId\":1414615,\"remitLinkId\":20}";
    }

    @Autowired
    private RepositoryService repositoryService;

    // 部署流程定义
    public String deploy() {
        try {
            Deployment deployment = repositoryService.createDeployment() // 创建部署
                    .addClasspathResource("bpmnfile/MyProcess111.bpmn.xml") // 加载流程资源文件
                    .name("测试任务退回") // 流程名称
                    .deploy(); // 部署
            System.out.println("流程部署ID:" + deployment.getId());
            System.out.println("流程部署Name:" + deployment.getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "{\"code\":200,\"msg\":\"短信申请发送成功！\",\"smsContent\":\"一口吃的监考老师，发现一个学生在作弊，便气急败坏地指着那学生吼道：“你…你…你…你…你竟敢作弊，站起来！ 话刚说完，有5名学生站了起来。！\",\"reqSerialNo\":\"192929229\",\"smsId\":1414615,\"remitLinkId\":20}";
    }

}
